<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

use Illuminate\Support\Facades\DB;
use App\Tools\Common;


$router = app('router');

$router->get('user', function () {
    return 'user';
});


$router->get('user/init', function () {

    return app('userService')->register([
        'nick_name' => '鱼生',
        'username' => 'guolu',
        'avatar' => 'https://mall-kxwh.oss-cn-hangzhou.aliyuncs.com/default/2023-08-03/ced5796cba1443a9b3d83b71d1e5bed3.png',
        'password' => 123456,
        'meta' => ['role_id' => ''],
        'gender' => 1,
        'type' => 2, // 管理员
        'bind_phone' => 13311187812,
    ]);

    return 'user';
});

// 用户管理 admin
$router->group(['namespace' => 'Packages\User\Controllers\Admin', 'prefix' => 'api/user'], function () use ($router) {
    $router->post('/list', 'UserController@list');
    $router->post('/all', 'UserController@all');
    $router->post('/register', 'UserController@register');
    $router->post('/info', 'UserController@userInfo');
    $router->post('/update', 'UserController@update');
    $router->post('/pass-reset', 'UserController@resetPass');
    $router->post('/login-update', 'UserController@loginUpdate');
    $router->post('/login', 'UserController@login');
    $router->post('/login-out', 'UserController@loginOut');
    $router->post('/status', 'UserController@statusUpdate');
});


// 用户管理 client
$router->group(['namespace' => 'Packages\User\Controllers\Client', 'prefix' => 'web/user'], function () use ($router) {
    $router->post('/register', 'UserController@register');
    $router->post('/info', 'UserController@userInfo');
    $router->post('/update', 'UserController@update');
    // $router->post('/login-update', 'UserController@loginUpdate');
    $router->post('/pass-update', 'UserController@updatePass');
    $router->post('/find-pass', 'UserController@findPassword');
    $router->post('/login', 'UserController@login');
    $router->post('/login-out', 'UserController@loginOut');
});
